﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test.Common
{
    public class OperResult<T>
    {
        /// <summary>
        /// 操作后返回的信息  true成功  false失败
        /// </summary>
        public bool States { get; set; }
        /// <summary>
        /// 错误信息
        /// </summary>
        public string  message { get; set; }
        /// <summary>
        /// 操作成功，返回的数据
        /// </summary>
        public T Data { get; set; } = default;

        /// <summary>
        /// 失败返回
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        public static OperResult<T> Failed(string message)
        {
            return new OperResult<T>
            {
                States=false,
                message=message
            };
        }
        /// <summary>
        /// 成功返回
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public static OperResult<T> Success(T data)
        {
            return new OperResult<T>
            {
                States = true,
                Data=data
            };
        }
    }
}
